package com.caregiver.watch.business.user.model.vo;

import com.caregiver.watch.business.user.enums.WeekDay;
import com.caregiver.watch.business.user.model.po.UserAlarmClockConfig;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.time.LocalTime;
import java.util.Set;

import static com.caregiver.watch.common.constant.NumberConstants.ONE_INTEGER;

/**
 * @Description: 用户闹钟配置
 * @Author 疆戟
 * @Date 2025/8/24 16:11
 * @Version 1.0
 */
@Data
@Schema(title = "用户闹钟配置")
public class UserAlarmClockConfigVo {
    @Schema(description = "ID")
    private Long id;
    @Schema(description = "用户ID")
    private Long userId;
    @Schema(description = "闹钟时间")
    @JsonFormat(pattern = "HH:mm")
    private LocalTime alarmTime;
    @Schema(description = "重复天")
    private Set<WeekDay> repeatDays;
    @Schema(description = "是否启用")
    private Boolean isEnabled;

    public static UserAlarmClockConfigVo build(UserAlarmClockConfig po) {
        UserAlarmClockConfigVo configVo = new UserAlarmClockConfigVo();
        configVo.id = po.getId();
        configVo.userId = po.getUserId();
        configVo.alarmTime = po.getAlarmTime();
        configVo.repeatDays = po.getRepeatDaysSet();
        configVo.isEnabled = ONE_INTEGER.equals(po.getIsEnabled());
        return configVo;
    }
}
